package com.cn.why.film.filmindex.repository;

import com.cn.why.film.filmindex.entity.PetProduce;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
public interface PetMartReposity extends JpaRepository<PetProduce,Integer>, JpaSpecificationExecutor<PetProduce> {
    /**
     * 按条件查找
     * @param msg2
     * @return
     */
    @Query(value = "select * from pet_produce where concat(pro_name,price,date_produce)like %?1%",nativeQuery = true)
    List<PetProduce> selectProByMsg(String msg2);

    /**
     * 打折商品
     * @return
     */
    @Query(value = "select * from pet_produce where discount = 1",nativeQuery = true)
    List<PetProduce> getDisCountPro();

    /**
     * 根据商品类型编号查询商品
     * @param proNumber
     * @return
     */
    @Query(value = "select * from pet_produce where pro_number = ?1",nativeQuery = true)
    List<PetProduce> getProduceByNumber(Integer proNumber);

    /**
     * 根据名字查询商品
     * @param petName
     * @return
     */
    @Query(value = "select * from pet_produce where pro_name = ?1",nativeQuery = true)
    List<PetProduce> getProduceByName(String petName);
}
